package com.ericom.model;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

@Entity
@Table(name = "return_goods_order_item")
public class ReturnGoodsOrderItem extends BaseObject {
	@Override
	public String toString() {
		return new ToStringBuilder(this).append("id", id)
				.append("product", product).append("price", price)
				.append("quntity", quntity)
				.append("returnGoodsOrder", returnGoodsOrder).toString();
	}

	@Override
	public boolean equals(final Object other) {
		if (!(other instanceof ReturnGoodsOrderItem))
			return false;
		ReturnGoodsOrderItem castOther = (ReturnGoodsOrderItem) other;
		return new EqualsBuilder().append(id, castOther.id).isEquals();
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder().append(id).toHashCode();
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "product_id")
	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public float getPrice() {
		return price;
	}

	public void setPrice(float price) {
		this.price = price;
	}

	@Column(name = "f_quantity")
	public float getQuntity() {
		return quntity;
	}

	public void setQuntity(float quntity) {
		this.quntity = quntity;
	}

	@ManyToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "return_goods_order_id")
	public ReturnGoodsOrder getReturnGoodsOrder() {
		return returnGoodsOrder;
	}

	public void setReturnGoodsOrder(ReturnGoodsOrder returnGoodsOrder) {
		this.returnGoodsOrder = returnGoodsOrder;
	}

	private Long id;
	private Product product;
	private float price;
	private float quntity;
	private ReturnGoodsOrder returnGoodsOrder;

}
